import sys


def convertNum(s):
    if len(s) == 0:
        return -1

    for i in s:
        if not i.isdigit():
            return -1

    ans = int(s)
    if 0 <= ans <= 255:
        return ans
    else:
        return -1


def parse(line: str):
    ip = []
    mask = []
    ipStr, maskStr = line.split('~')

    for num in iter(ipStr.split('.')):
        ip.append(convertNum(num))
    for num in iter(maskStr.split('.')):
        mask.append(convertNum(num))

    if ip[0] == 0 or ip[0] == 127:
        return None
    else:
        return {'ip': ip, 'mask': mask}


def isLegalIP(ip):
    for num in ip:
        if num == -1:
            return False
    return True


def isLegalMask(mask):
    findZero = False
    findOne = False
    for num in mask:
        if num == -1:
            return False
        bits = bin(num)[2:]
        bits = '0'*(8-len(bits)) + bits
        for c in bits:
            if c == '0' and not findZero:
                findZero = True
            elif c == '1' and not findOne:
                findOne = True

            if findZero and c == '1':
                return False

    if findZero and findOne:
        return True
    else:
        return False


def isPrivateIP(ip):
    if ip[0] == 10:
        return True
    elif ip[0] == 172 and 15 < ip[1] < 32:
        return True
    elif ip[0] == 192 and ip[1] == 168:
        return True

    return False


lines = []

try:
    while True:
        line = input()
        if line == '':
            break
        lines.append(line)
except:
    pass

ans = {'A': 0, 'B': 0, 'C': 0, 'D': 0,
       'E': 0, 'illegal': 0, 'private': 0}
for line in lines:
    if line == '':
        break
    info = parse(line)
    if info == None:
        continue
    ip = info['ip']
    mask = info['mask']
    if isLegalIP(ip) and isLegalMask(mask):
        if 0 < ip[0] < 127:
            ans['A'] += 1
        elif 127 < ip[0] < 192:
            ans['B'] += 1
        elif 191 < ip[0] < 224:
            ans['C'] += 1
        elif 223 < ip[0] < 240:
            ans['D'] += 1
        elif 239 < ip[0] < 256:
            ans['E'] += 1

        if isPrivateIP(ip):
            ans['private'] += 1
    else:
        ans['illegal'] += 1

for type in ans:
    print(ans[type], end=' ')
